<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="" />
    <meta name="author" content="ChongMing" />
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="full-screen" content="yes">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="360-fullscreen" content="true">
    <title>会员详情</title>
</head>
<link rel="stylesheet" href="../css/framework7.ios.min.css">
<link rel="stylesheet" href="../css/framework7.ios.colors.min.css">
<link rel="stylesheet" href="../css/my-app.css">
<link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="../css/swiper-3.3.1.min.css">
<link rel="stylesheet" href="css/membercenter.css">
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.mobile-1.4.3.js"></script>
<script type="text/javascript" src="../js/swiper-3.3.1.jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/membercenter.js"></script>
<script src="js/ap.js"></script>
<script src="js/pingpp.js"></script>
<script type="text/javascript">
    $(function(){
        var id = membercenter.getQueryString('product_id');
        var data = {product_id:id};
        var uid = $.cookie("local_userId");
        membercenter.showtime();
        membercenter.produdatail('memberCenter/productDetail',data);
        membercenter.get('memberCenter/productDetail',data,function(res){
            if(res.ret==0){
                var data = res.data;
                var time = data.diff_end_promotion;
                time1 = setInterval(function(){
                    time--
                    membercenter.showtime(time);
                },1000);
            }
            else{
                alert(res.msg);
            }
        });
        $('#purchase').click(function(){
            $('.payment-layer').fadeIn();
            $('.gradecard .payment-layer .con').animate({'bottom':'0px'},300);
            var product_category = $('body').data('product_category')
            var money_num = $(this).data('price');

            $.ajax({
                type : 'get',
                url : 'http://ekang.ren/diagnosis/submitUserServiceOrder',
                dataType : 'jsonp',
                data : {total_amount:money_num,product_id:id,uid:uid},
                success : function(res) {
                    var data = res.data;
                    order_id = data.order_id;
                    if(res.ret==0){
                        console.log(res);
                        $('.gradecard .payment-layer .con .userinfor .left .head_pic').attr('style',' background: url('+ data.avatar_file+') center; background-size: cover;');
                        $('.gradecard .payment-layer .con .userinfor .left .name_time .name').html(data.user_name);
                        $('.gradecard .payment-layer .con .userinfor .left .name_time .time').html(data.service_start+'-'+data.service_end);
                        $('.gradecard .payment-layer .con .userinfor .right img').attr('src',data.max_product_img);
                        $('.gradecard .payment-layer .con .userinfor .right p').html(data.product_name);
                        $('.gradecard .payment-layer .con .time .p2').html(data.service_start_1+'-'+data.service_end_1);
                        if(product_category==0){
                            $('.gradecard .payment-layer .con .money-num .p2').html(data.total_amount);
                        }else{
                            $('.gradecard .payment-layer .con .money-num .p2').html(data.origin_total_amount);
                        }
                        $('.gradecard .payment-layer .con .contact-time').html( data.total_amount+'（'+data.promotion_price+'折）');
                    }else{
                        console.log(res.msg);
                    }
                }
            });
//            membercenter.get('memberCenter/getUserMemberInfo',{},function(res){
//                if(res.ret==0){
//                    console.log(res);
//                    var data = res.data;
//                }
//                else{
//                    alert(res.msg);
//                }
//            });
        });
        if($.cookie("is_wechat")==1){
            pay_mode = 'alipay_wap';
            $('.gradecard .payment-layer .con .pay-mode .wechat .radio').removeClass('hover');
            $('.gradecard .payment-layer .con .pay-mode .wechat').hide();
            $('.gradecard .payment-layer .con .pay-mode .alipay .radio').hide();
        }else{
            pay_mode = 'wx_pub';
        }
        $('.gradecard .payment-layer .con .button-pay').click(function(){
            if($('.gradecard .payment-layer .con .pay-mode .wechat .radio').hasClass('hover')){
                pay_mode = 'wx_pub';
            }else{
                pay_mode = 'alipay_wap';
            }
            code = membercenter.getQueryString("code");
            $.ajax({
                type: 'GET',
                url:  'http://ekang.ren/diagnosis/getcharge/',
                data: {         // 需要于客户端同步
                    order_id: order_id,
                    pay_method:pay_mode,
                    uid:uid,
                    code : code
                },
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (result) {
                    if(result.ret){
                        alert(result.msg);
                    }
                    pingpp.createPayment(result.data.charge, function(result, err) {
                        if (result=="success") {
                            location.href = '../memberCenter/index.html'
                        } else {

                        }
                    });
                }
            });
        });
    });
</script>
</body>
<body style=" background: #ebebeb;  margin: auto;-webkit-overflow-scrolling: touch;overflow: scroll;">
<div class="gradecard">
    <div class="countdown">
        <p>距离结束</p>
        <div class="time" id="countdown">
            <div class="hour public"></div>
            <div class="dd">:</div>
            <div class="minute public"></div>
            <div class="dd">:</div>
            <div class="second public"></div>
        </div>
    </div>
    <div class="cardlist">
        <div class="con">
            <div class="cardtype">
                <div class="left">
                    <img src="" alt="">
                    <p class="name"></p>
                </div>
                <div class="right">
                    <span class="span1"></span>
                    <span class="span2"></span>
                </div>
            </div>
            <div class="servicecontent">

            </div>

            <button class="purchase" id="purchase">立即抢购</button>
        </div>
    </div>
    <div class="welfaretext public">
        <div class="tit">
            <p class="l">会员福利</p>
            <p class="r">开通之日起一月之内</p>
        </div>
        <div class="text">

        </div>
    </div>
    <div class="remarks public">
        <div class="tit">
            <p class="l">备注声明</p>
        </div>
        <div class="text">

        </div>
    </div>
    <div class="payment-layer">
        <div class="topmask"></div>
        <div class="con">
            <div class="userinfor">
                <div class="left">
                    <div style=" background: url(images/mrtx.png) center; background-size: cover;" class="head_pic"></div>
                    <div class="name_time">
                        <p class="name"></p>
                        <p class="time"></p>
                    </div>
                </div>
                <div class="right">
                    <img src="">
                    <p></p>
                </div>
            </div>
            <div class="time public">
                <p class="p1">会员时间</p>
                <p class="p2"></p>
            </div>
            <div class="money-num public">
                <p class="p1">充值金额</p>
                <p class="p2"></p>
            </div>
            <div class="pay-mode">
                <p class="p1">支付方式</p>
                <div class="wechat public">
                    <img class="icon-wechat img" src="images/icon42.png">
                    <img class="radio hover" src="images/icon41.png">
                </div>
                <div class="alipay public">
                    <img class="icon-alipay img" src="images/icon43.png">
                    <img class="radio" src="images/icon40.png">
                </div>
            </div>
            <span class="contact-time"></span>
            <button class="button-pay">支付</button>
        </div>
    </div>
</div>
</body>
</html>